<%--
 *  File:    EmployeeAllWindow.jsp
 *  @Author: jackyin
 *  Date:    2011/02/17
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>



<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.EmployeeAllWindow");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
String privilegeCode = "All";
String strTableName = "v_employeeallsummary";
String strModuleName = "COM";
String contextPath = request.getContextPath();

%>



<%
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	Integer nCurOrgId = (Integer)CurUserInfo.get("orgid");
  	String strCurUserName = (String)CurUserInfo.get("username");
  	Integer nCurUserId = (Integer)CurUserInfo.get("userid");
  	String isPrimaryAdmin = (String)CurUserInfo.get("isprimaryadmin");
  	if(isPrimaryAdmin == null)
  	{
    	isPrimaryAdmin = "";
  	} 
  	//give permission
  	boolean bCanUpdatePrimaryAdmin = true;
  	if(!isPrimaryAdmin.equalsIgnoreCase("Y"))
  	{
    	bCanUpdatePrimaryAdmin = false;
  	} 
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>ContactSummaryForPop</title>
<PageFlow:CheckPageFlow pageName="P_zylemployeeallsummary"/>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script>
isRunning=false;
</script>
<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%

  	Vector searchresults  = (Vector)pageContext.getAttribute("searchresults");
  	if(searchresults  == null)
  		searchresults  = new Vector();
%>
<script>
function clickUser(id,username,employeename,employeeid,employeecode,deptid)
{
  document.usersummaryform.userid.value = id;
  document.usersummaryform.username.value = username;
  document.usersummaryform.employeename.value = employeename;
  document.usersummaryform.employeeid.value = employeeid;
  document.usersummaryform.employeecode.value = employeecode;
  document.usersummaryform.deptid.value = deptid;
}

function closeWindow(){

	var userid = document.usersummaryform.userid.value;
	var employeename = document.usersummaryform.employeename.value;
	var username = document.usersummaryform.username.value;
	var employeeid = document.usersummaryform.employeeid.value;
	var employeecode = document.usersummaryform.employeecode.value;
	var deptid = document.usersummaryform.deptid.value;
	opener.setContact(userid,username,employeename,employeeid,employeecode,deptid);
	window.close();
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(usersummaryform,actionvalue,orderbyname);
  editform.action = "EmployeeAllWindow.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

	<% //--------------------------------------  hidden form variant --%>
	<form name="usersummaryform" method="post" action="<%=contextPath %>/Dispatcher"  target="_parent">
      <input type="hidden" name="pagename" value="P_zylemployeeallsummary">
    <input type="hidden" name="actionname">
 
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr> 
    	<td valign="top"> 
        	<table width="100%" border="0" cellspacing="0">
          	<tr> 
            	<td class="summary_top" ></td> 
          	</tr>
        	</table>
        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
          	<tr> 
            <td>
            	<table>
            		<%@ include file="/inc/SummarySearch.inc" %>
            	</table>
            </td>
          </tr>
        </table>
        
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
        
        <% //--------------------------------------  summary header --%>
        <tr bgcolor="#ACBCCA" class="deepblue-left">
        	<td width="2%" class="title_center">&nbsp;</td>
            <td width="*" class="title_center"><a href="javascript:page_summary('orderby','username')"><%= label.getLabelName("L_UserName") %></a></td>
            <td width="35%" class="title_center"><a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_EmployeeName") %></a></td>
       	</tr>
        
        <% //--------------------------------------  default value definition --%>
        <%
        	int i = 0;
            String strClassType = new String();   
            Integer nDefaultUserId = null; 
            String strIsPrimaryAdmin = "";
            boolean bHasChecked = false;   
            String strDefaultIsDisabled="";
        		String strDefaultUserName="";  
        		String strDefaultEmployeeName = "";
        		Integer strDefaultEmployeeId= null;  
        		String strDefaultEmployeeCode = "";
        		Integer strDefaultEmployeeDeptid= null;  
        		
      	%>
        
        <% //--------------------------------------  loop results --%>
        <logic:iterate id="usersum" collection="<%= searchresults  %>">                      
        <%
        	HashMap userMap = (HashMap)pageContext.getAttribute("usersum"); 
            String strUserName = (String)userMap.get("username");  
            String userIsPrimaryAdmin = (String)userMap.get("isprimaryadmin");
            String strIsDisabled = new String("");
            String strIsChecked = new String("");
            
            if(i%2 == 1)
            {
              	strClassType = "td-listrom";
            }else{                    
              	strClassType = "";
            }
            if(!bCanUpdatePrimaryAdmin && "Y".equalsIgnoreCase(userIsPrimaryAdmin) && nCurOrgId.equals((Integer)userMap.get("orgid")) )
            {
               strIsDisabled = new String(" Disabled ");
               userMap.put("userid","-1");
            } 
            else if(!bHasChecked)
            {
                strIsChecked = "Checked";
                bHasChecked = true;
                nDefaultUserId = (Integer)(userMap.get("userid"));
                strIsPrimaryAdmin = (String)(userMap.get("isprimaryadmin"));
                strDefaultUserName= (String)(userMap.get("username"));
                strDefaultEmployeeName = (String)(userMap.get("employeename"));
                strDefaultEmployeeId = (Integer)(userMap.get("employeeid"));
                strDefaultEmployeeCode = (String)(userMap.get("employeecode"));
                strDefaultEmployeeDeptid = (Integer)(userMap.get("deptid"));
                strDefaultIsDisabled = strIsDisabled;
            }
            i++;                         
          %>
          
     	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue('user<%=JspHelper.filterNull( i )%>');;clickUser('<%=JspHelper.filterNull( userMap.get("userid") )%>','<%=JspHelper.filterNull( userMap.get("username") )%>','<%=JspHelper.filterNull( userMap.get("employeename") )%>','<%=JspHelper.filterNull( userMap.get("employeeid") )%>','<%=JspHelper.filterNull( userMap.get("employeecode") )%>','<%=JspHelper.filterNull( userMap.get("deptid") )%>');" class="<%=JspHelper.filterNull( strClassType )%>"> 
        	<td width="5%" class="<%=JspHelper.filterNull( strClassType )%>">
            	<input type="radio" id="user<%=JspHelper.filterNull( i )%>" name="checkuser" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( userMap.get("userid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked )%>>
            </td>
            <td width="50%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userMap.get("username") )%></td>
            <td width="50%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( userMap.get("employeename") )%></td>
     	</tr>
        </logic:iterate>                   
        
        <% //--------------------------------------  default value --%>       
        <input type="hidden" name="userid" value="<%=JspHelper.filterNull( nDefaultUserId )%>">
        <input type="hidden" name="ispa" value="<%=JspHelper.filterNull( strIsPrimaryAdmin )%>">
				<input type="hidden" name="username" value="<%=JspHelper.filterNull( strDefaultUserName )%>">  
    		<input type="hidden" name="editflag" value="<%=JspHelper.filterNull( strDefaultIsDisabled )%>">
    		<input type="hidden" name="employeename" value="<%=JspHelper.filterNull( strDefaultEmployeeName )%>">
    			<input type="hidden" name="employeeid" value="<%=JspHelper.filterNull( strDefaultEmployeeId )%>">
    				<input type="hidden" name="employeecode" value="<%=JspHelper.filterNull( strDefaultEmployeeCode )%>">
    				<input type="hidden" name="deptid" value="<%=JspHelper.filterNull( strDefaultEmployeeDeptid )%>">
    			
    				
        <% //--------------------------------------  flipping page --%>
    	<%@ include file="/inc/SummaryAction.inc" %>
          
        </table>
        
        <% //--------------------------------------  page operation button --%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        	<tr> 
            	<td class="summary_top" ></td>
          	</tr>
          	<tr> 
            	<td class="td_center">
            		<a onclick="closeWindow()"><custom:button type="1" label="L_Ok" imgsrc="edit.gif" border="0" style="width:60"/></a>
            		<!--<a onclick="page_deptedit();"><input type="button" class="button1" value="\ufffd\ufffd\ufffd\ufffd\u03ac\ufffd\ufffd" border="0" style="width:60"></a>-->
            	</td>
          	</tr>
        </table>
        
  	</td>
</tr>
</table>
</form>
</body>
</html>
<script>
isRunning=false;
</script>

